# -*- coding: utf-8 -*-
# @Time: 2021/8/20 8:25
# @File: arg-13.py
# @DESC:

def func1(s):
    SYMBOL_VALUES = {
        'I': 1,
        'V': 5,
        'X': 10,
        'L': 50,
        'C': 100,
        'D': 500,
        'M': 1000,
    }
    sum = 0
    lent = len(s)
    for index, i in enumerate(s):
        if index < lent - 1 and SYMBOL_VALUES[i] < SYMBOL_VALUES[s[index + 1]]:
            sum -= SYMBOL_VALUES[i]
        else:
            sum+=SYMBOL_VALUES[i]
    return sum


s = "IX"
r = func1(s)
print(r)
